<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script src="jquery-1.7.2.js" type="text/javascript" charset="utf-8"></script>
<script>
$(document).ready(function(){
	$("#search").click(function(){
		alert($("#method").val()+","+$("#search_title").val());
		$.ajax({
			type:"post",
			url:"admin.do",
			data:"command=searchMovie&method="+$("#method").val()+"&search_title="+$("#search_title").val(),
			dataType:"json",
			success:function(js){
				if(js.list==""){
					alert("검색 결과가 없습니다.");
					$("#movie_list").html("");
					return false;
				}
				var data = js.list;
				var list = "<b> 검색 결과 </b>";
				list+="<table border='1' cellspacing='0' width='90%' cellpadding='7'><tr bgcolor='#f5f5f5' align='center'><td width='120'>영화번호</td><td>영화제목</td><td width='250'>공식개봉일</td></tr>";
				$.each(data,function(indexl,value){
					list+="<tr align='center'><td>"+value.movie_no+"</td><td><a href='admin.do?command=showMovieDetail&movie_no='"+value.movie_no+"'></a>"+value.movie_title+"</td><td>"+value.opening_day+"</td></tr>";
				});
				list+="</table>";
				$("#movie_list").html(list);
			}
		});//ajax
	});//search
});//raedy
	
</script>
<c:choose>
<c:when test="${sessionScope.vo.memberlevelinfoVO.member_level_no !=1}">
<script>
	alert("잘못된 접근입니다!");           
	location.href="mycinema.do?command=home_main";
</script>
</c:when>
<c:when test="${sessionScope.vo.memberlevelinfoVO.member_level_no ==1}">
<font class='title'>영화 목록</font><hr color="#f5f5f5">
※영화제목 클릭시 영화 상세정보 페이지로 이동 합니다.<br>
검색방법
<select id="method">
	<option value="">- - - - - - -</option>
	<option value="title"> 영화제목 </option>
	<option value="genre"> 장   르 </option>
	<option value="country"> 나    라 </option>
</select>
&nbsp;&nbsp;<b> 검 색 </b><input type="text" name="search_title" id="search_title"><input type="button" id="search" value="검색">
<div id="movie_list"></div>
<hr>
<b>전체 movie list</b>
<table border='1' cellspacing='0' width='90%' >
	<tr bgcolor="#f5f5f5" align='center' >
		<td width='120'> 영화번호 </td>
		<td> 영화제목 </td>
		<td width='250'> 공식 개봉일</td>
	</tr>
	<c:forEach items="${requestScope.info}" var="list">
	<tr align='center'>	
		<td>${list.movie_no}</td>
		<td><a href="admin.do?command=showMovieDetail&movie_no=${list.movie_no}">${list.movie_title}</a></td>
		<td>${list.opening_day}</td>
	</tr>
	</c:forEach>
</table>
</c:when>
</c:choose>



